#ifndef _CFRAME_CHILDRENS_H
#define _CFRAME_CHILDRENS_H

#include "CFrame.h"
#include <wx/numdlg.h>
#include <wx/dynarray.h>


class ScrolledImageComponent : public wxScrolledWindow
{
    wxBitmap* bitmap;
    int w,h;
public:
    ScrolledImageComponent(wxWindow* parent, wxWindowID id, wxString image_path) : wxScrolledWindow(parent, id, wxPoint(50,50), wxSize(256,256))
    {
        wxImage image(image_path);
        if(!image.IsOk())
        {
            wxMessageBox(wxT("there was an error loading the image"));
            return;
        }
        
        w = image.GetWidth();
        h = image.GetHeight();
 
        /* init scrolled area size, scrolling speed, etc. */
        SetScrollbars(1,1, w, h, 0, 0);
        
        bitmap = new wxBitmap( image );
    }
    ~ScrolledImageComponent()
    {
        //delete bitmap;
    }
    void OnDraw(wxDC& dc)
    {
        /* render the image - in a real app, if your scrolled area
           is somewhat big, you will want to draw only visible parts,
           not everything like below */
        dc.DrawBitmap(*bitmap, 0, 0, false);
    }
};

//=================================================================//
//Name: GUI Image Note class
//targets: Contains all information about image and is 
//		   responsible for its displaing in the main window
//=================================================================//


class HistoryNode
{
private:
	wxTreeItemId m_id;
	wxDateTime m_created;
	__int64 m_processed;
    wxString m_description;
    roPreImage* m_image;
public:
	HistoryNode(wxTreeItemId id, roPreImage* image, const wxString &description, __int64 processed = -1)
	{
		Init(id, image, description, processed);
	}
	void Init(wxTreeItemId id, roPreImage* image, const wxString &description, __int64 processed)
	{
		SetId(id);
		m_description = description;
		m_image = image;
		m_created = wxDateTime::Now();
		m_processed = processed;
	}
	const wxString GetDescription()
	{
		return m_description;
	}
	
	const wxTreeItemId GetId()
	{
		return m_id;
	}

	roPreImage* GetImage()
	{
		return m_image;
	}

	void SetId(wxTreeItemId id)
	{
		m_id = id;
	}

	wxDateTime GetGenDate()
	{
		return m_created;
	}
	long long GetProcessTime()
	{
		return m_processed;
	}
};



//WX_DECLARE_OBJARRAY(HistoryNode, HistoryArray);
//WX_DECLARE_HASH_MAP(wxTreeItemId, HistoryNode*, wxIntegerHash,
//                    wxIntegerEqual, HistoryArray);
WX_DECLARE_LIST(HistoryNode, HistoryList);


class GuiInote : public AUI_CFrame
{
private:
	wxTreeCtrl * m_TreeCtrl;
	wxBitmap * Bitmap;
	ImageLoader * m_il;

	HistoryList* m_history;
	__int64 m_inprocess;		//msec 
	wxTreeItemId m_currentItem;
	wxTreeItemId m_onScreenItem;
public:
//image properties
	wxString m_path;
	wxImage * m_source;
	wxSlider *m_slider;

	wxSizer *m_sizerSlider;
private:
	/*this method will be called automaticly!*/
	void CreateControls();
	HistoryNode* GetNodeByTreeItem(wxTreeItemId item, bool* res = NULL);
	void SelectActiveImage(roPreImage * image);	
public:
	/*Image handlers function*/
	bool RegisterImage(wxString path);
	GuiInote();
	~GuiInote();

	void CreateSlider();
	void AddHistoryPanel();
	void SetImage(roImage * image, const wxString &description, bool overload = true);
	roImage * GetImage();
	
public:
	void OnTreeItemRClick(wxTreeEvent& event);
	void OnTreeItemActivated(wxTreeEvent& event);
	void OnDoubleClick(wxMouseEvent& WXUNUSED(evt));
	void ShowContextMenu(const wxPoint& pos);
	void ShowTreeMenu(wxTreeItemId id, const wxPoint& pt);
	void OnTreeMenu_Properties(wxCommandEvent & event);
	void OnTreeMenu_Compare(wxCommandEvent & event);
    void OnRightUp(wxMouseEvent& event);

	void OnSlider(wxScrollEvent& event);

	

	 
	
	DECLARE_EVENT_TABLE()
};

//WX_DECLARE_OBJARRAY(GuiInote, GuiInoteArray);


#endif

